package leetcode.jianzhioffer;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-11-13 00:01
 **/
public class JianZhiOffer57II {

    public int[][] findContinuousSequence(int target) {
        List<int[]> list = new ArrayList<>();
        for (int l = 1, r = 2; l < r;) {
            int sum = (l + r) * (r - l + 1) / 2;
            if (sum == target) {
                int[] nums = new int[r - l + 1];
                for (int i = l; i <= r; i++) {
                    nums[i - l] = i;
                }
                list.add(nums);
                l++;
            } else if (sum < target) {
                r++;
            } else {
                l++;
            }
        }
        return list.toArray(new int[list.size()][]);
    }

}
